import { IReport, IReportParams } from '../interface/reports';
import * as request from './request';

export async function getAllReport(body: IReportParams) {
  try {
    const login = sessionStorage.getItem('login')?.toString();
    if (login === '1') {
      const data = await request.post(
        JSON.stringify(body),
        '/api/console/report/get',
      );
      return data;
    } else {
      return {};
    }
  } catch (e) {
    return e;
  }
}

export async function doBan(body: IReport) {
  try {
    const data = await request.post(
      JSON.stringify(body),
      '/api/console/report/ban',
    );
    return data;
  } catch (e) {
    return e;
  }
}

export async function changeDoneStatus(body: { id: string }) {
  try {
    const data = await request.post(
      JSON.stringify(body),
      '/api/console/report/changeDone',
    );
    return data;
  } catch (e) {
    return e;
  }
}

export async function changeStatus(body: { id: string }) {
  try {
    const data = await request.post(
      JSON.stringify(body),
      '/api/console/report/changeStatus',
    );
    return data;
  } catch (e) {
    return e;
  }
}
